package com.springboot.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.springboot.po.*;

@Mapper
public interface DeliveryAddressMapper {
	
	@Select("select * from deliveryAddress where userId = #{userId} order by daId")
	public List<DeliveryAddress> listDeliveryAddressByUserId(String userId);
	//CRUD
	@Select("select * from deliveryAddress where daId = #{daId}")
	public DeliveryAddress getDeliveryAddressById(Integer daId);
	@Insert("insert into deliveryAddress values(null,#{contactName},#{contactSex},#{contactTel},#{address},#{userId} , 0)")
	public int saveDeliveryAddress(DeliveryAddress deliveryAddress);
	//update也是新建一个地址并且把之前的地址设置成为remark=1
	@Update("update deliveryAddress set  remark = 1 where daId = #{daId}")
	public int updateDeliveryAddress(DeliveryAddress deliveryAddress);
	//delete只是remark=1
	@Update("update deliveryAddress set  remark = 1 where daId = #{daId}")
	public int removeDeliveryAddress(Integer daId);

}
